package com.boot.security.server.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.Drafts;

@Mapper
public interface DraftsDao {

    @Select("select * from m_drafts t where t.id = #{id}")
    Drafts getById(Long id);

    @Delete("delete from m_drafts where id = #{id}")
    int delete(Long id);

    int update(Drafts drafts);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into m_drafts(branch, branch_id, check_status, create_time, end_patrol_time, oversee, oversee_form, oversee_id, question, question_detail, question_keyword, question_status, question_type, remark, start_patrol_time, update_time) values(#{branch}, #{branchId}, #{checkStatus}, #{createTime}, #{endPatrolTime}, #{oversee}, #{overseeForm}, #{overseeId}, #{question}, #{questionDetail}, #{questionKeyword}, #{questionStatus}, #{questionType}, #{remark}, #{startPatrolTime}, #{updateTime})")
    int save(Drafts drafts);
    
    int count(@Param("params") Map<String, Object> params);

    List<Drafts> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
